package com.mall.business.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
        import com.mall.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.mall.business.mapper.TOrderItemMapper;
import com.mall.business.domain.TOrderItem;
import com.mall.business.service.ITOrderItemService;

/**
 * 订单明细项Service业务层处理
 *
 * @author ruoyi
 * @date 2025-03-30
 */
@Service
public class TOrderItemServiceImpl extends ServiceImpl<TOrderItemMapper,TOrderItem>  implements ITOrderItemService
{
    @Autowired
    private TOrderItemMapper tOrderItemMapper;

    /**
     * 查询订单明细项
     *
     * @param orderItemId 订单明细项主键
     * @return 订单明细项
     */
    @Override
    public TOrderItem selectTOrderItemByOrderItemId(String orderItemId)
    {
        return tOrderItemMapper.selectTOrderItemByOrderItemId(orderItemId);
    }

    /**
     * 查询订单明细项列表
     *
     * @param tOrderItem 订单明细项
     * @return 订单明细项
     */
    @Override
    public List<TOrderItem> selectTOrderItemList(TOrderItem tOrderItem)
    {
        return tOrderItemMapper.selectTOrderItemList(tOrderItem);
    }

    /**
     * 新增订单明细项
     *
     * @param tOrderItem 订单明细项
     * @return 结果
     */
    @Override
    public int insertTOrderItem(TOrderItem tOrderItem)
    {
                tOrderItem.setCreateTime(DateUtils.getNowDate());
            return tOrderItemMapper.insertTOrderItem(tOrderItem);
    }

    /**
     * 修改订单明细项
     *
     * @param tOrderItem 订单明细项
     * @return 结果
     */
    @Override
    public int updateTOrderItem(TOrderItem tOrderItem)
    {
                tOrderItem.setUpdateTime(DateUtils.getNowDate());
        return tOrderItemMapper.updateTOrderItem(tOrderItem);
    }

    /**
     * 批量删除订单明细项
     *
     * @param orderItemIds 需要删除的订单明细项主键
     * @return 结果
     */
    @Override
    public int deleteTOrderItemByOrderItemIds(String[] orderItemIds)
    {
        return tOrderItemMapper.deleteTOrderItemByOrderItemIds(orderItemIds);
    }

    /**
     * 删除订单明细项信息
     *
     * @param orderItemId 订单明细项主键
     * @return 结果
     */
    @Override
    public int deleteTOrderItemByOrderItemId(String orderItemId)
    {
        return tOrderItemMapper.deleteTOrderItemByOrderItemId(orderItemId);
    }


    @Override
    public  List<TOrderItem> getOrderItemsByOrderNumber(String orderNo){
        TOrderItem tOrderItem = new TOrderItem();
        tOrderItem.setOrderNo(orderNo);
        List<TOrderItem> tOrderItems = tOrderItemMapper.selectTOrderItemList(tOrderItem);
        return  tOrderItems;
    }
}
